from pymysql import Connection

# 连接mysql数据库
# conn连接对象
conn = Connection(
    host='localhost',
    port=3306,
    user='root',
    password='gf767676',
    # autocommit=True #设置自动提交，就不需要commit
)
print(conn.get_server_info())

course = conn.cursor() #游标对象
conn.select_db('test')
#execute 执行sql方法
# course.execute("select * from student")
#fetchall获取查询结果
# result = course.fetchall()
# print(result)
# print(type(result)) #元组
# for row in result:
#     print(row)

# 修改sql语句需要commit进行确认
course.execute("INSERT INTO student Values(67,'lz',27)")
conn.commit()
conn.close()